<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>管理员登陆</title>
  <link rel="stylesheet" href="../css/bootstrap.min.css">
  <style>
    #login{
      width: 400px;
      margin: 150px auto;
    }
    #alert_info{
      margin: 2px;
      padding: 2px;
      text-align: center;
      margin-bottom: 10px;
      /* 不为被隐藏的对象保留其物理空间 */
      display: none;
    }
  </style>
  <script src="../myjs/ajax.js"></script>
  <script>
    window.onload = function(){
      var oBtn = document.getElementById("btn1");
      var aInput = document.getElementsByTagName("input");
      var oAlert = document.getElementById("alert_info");
      oBtn.onclick = function(){
        $ajax({
          method:"post",
          url:"guanliLogin1.php",
          data:{
            username:aInput[0].value,
            password:aInput[1].value
          },
          success:function(result){
            var obj = JSON.parse(result);
            // console.log(obj);
            if(obj.code){
              oAlert.className = 'alert alert-danger';
            }else{
              oAlert.className = 'alert alert-success';
              setTimeout(function(){
                location.href = "choose.html";
              },2000);
            }
            oAlert.style.display = "block";
            oAlert.innerHTML = obj.message;
          },
          error:function(msg){
            alert(msg);
          }
        })
      }

    }
  </script>
</head>

<body style="background-image:url(../imgs/1.jpg);background-repeat:no-repeat;background-attachment:fixed;background-size:cover">
  <div class="container">
    <div class="panel panel-primary" id="login">
      <div class="panel-heading">
        管理员登陆
      </div>
      <div class="panel-body">
        <div class="form-group">
          <label for="username" >用户名</label>
          <input type="text" name="username" class="form-control" id="">
        </div>
        <div class="form-group">
          <label for="password" >密码</label>
          <input type="text" name="password" class="form-control" id="">
        </div>
        <div class="alert alert-danger" role="alert" id="alert_info">xxx</div>
        <a href="guanliRegister.html">马上注册</a>
        <button class="btn btn-primary pull-right" id="btn1">登陆</button>
      </div>
    </div>
  </div>
</body>

</html>